<div id="userManager">
<div id="tabs-1">
<form method="post" action="#">
	<fieldset>
		<legend>Search</legend>
			<p>
		 		<label for="mf">User: </label>
 				<input class="user_name" name="user_name" type="text" value="<?php echo @$user_name;?>" /> 
			</p>
            <p>
				<label for="mf">User comment: </label>
 				<input class="user_comment" name="user_comment" type="text" value="<?php echo @$user_comment;?>" /> 
			</p>
            <p>
				<label for="mf">Parent ID: </label>
 				<input class="parent_id" name="parent_id" type="text" value="<?php echo @$parent_id;?>" /> 
			</p>
			<p>
				<label for="dropdown">Trạng thái: </label>
				<select name="dropdown" class="statsSearch">
					<option value="0"></option>
					<option value="1">Đã xóa</option>
					<option value="2">Đang hiển thị</option>
				</select>
			</p>
			<p>
				<input  class="buttonSearch" type="button" value="Search" />
			</p>
	</fieldset>
</form>
</div>
<div id="tabs-2">
<?php if($dataview){?>
	<table class="fullwidth" cellpadding="0" cellspacing="0" border="0">
		<thead>
			<tr>
				<td>STT</td>
				<td>User</td>
				<td>User comment</td>
                <td>Level</td>
                <td>Parent Id</td>
				<td>Nội dung</td>
				<td>Ngày tạo</td>
				<td>Ngày sửa</td>
				<td>Trạng thái</td>
				<td>Thao tác</td>
			</tr>
		</thead>
		<?php
 		foreach ($dataview as $view){
		?>
        <tbody>
            <tr <?php if($view['delete_flag'] == 1){ echo 'class="odd"'; }?>>
                <td><?php echo $view['stt']; ?></td>
                <td><?php echo @$arrUserInfo[$view['user_id']]; ?></td>
                <td><?php echo @$arrUserInfo[$view['user_comment_id']]; ?></td>
                <td><?php echo $view['level']; ?></td>
                <td><?php echo $view['parent_id'] == 0 ? '-' : $view['parent_id']; ?></td>
                <td><?php echo $view['content']; ?></td>
                <td><?php echo date('d-m-Y G:i:s',$view['create_time']); ?></td>
                <td><?php echo date('d-m-Y G:i:s',$view['update_time']); ?></td>
                <td><?php echo $view['stats']; ?></td>
                <td><?php if($view['delete_flag'] == 0){ ?><a style="text-decoration: none; color: blue;" href="/CommentManager/index?cmd=del&id=<?php echo $view['id'];?>">Xóa</a><?php }else{ echo '-';} ?></td>
            </tr>
        </tbody>
        <?php
		}
		?>
		
	</table>
    <?php
		}else{
    ?>
    <span class="validate_success">A positive message!</span>
	<?php }?>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
    $(".buttonSearch").click(function(e){
         var userName = $(".user_name").val();
         var user_comment = $(".user_comment").val();
         var statsSearch = $(".statsSearch").val();
         var parent_id = $(".parent_id").val();
         var url = '';
         if(userName)
            url += '&u='+userName;
         if(user_comment)
            url += '&c='+user_comment;
         if(statsSearch)
            url += '&s='+statsSearch;
        if(parent_id)
            url += '&pid='+parent_id;
         window.location.href = '/CommentManager/index?cmd=search'+url
    });
    $(".user_name,.user_comment,.parent_id").keypress(function(e){
        var code = (e.keyCode ? e.keyCode : e.which);
        if(code == 13){
            var userName = $(".user_name").val();
            var user_comment = $(".user_comment").val();
            var statsSearch = $(".statsSearch").val();
            var parent_id = $(".parent_id").val();
            var url = '';
            if(userName)
                url += '&u='+userName;
            if(user_comment)
                url += '&c='+user_comment;
            if(statsSearch)
                url += '&s='+statsSearch;
            if(parent_id)
                url += '&pid='+parent_id;
            window.location.href = '/CommentManager/index?cmd=search'+url
            return false;
        }
    });
});
</script>
